package gsc.org.tokenizer;

/**
 * Created with IntelliJ IDEA.
 * User: gianluca
 * Date: 02/04/13
 * Time: 16.58
 * To change this template use File | Settings | File Templates.
 */
public class Token {
    private String image;
    private TokenType type;
    private final int lineNumber;

    public Token(TokenType tokenType, String img, int lineNumber) {
        this.image = img;
        this.type = tokenType;
        this.lineNumber = lineNumber;
    }

    public Token(TokenType tokenType, Integer value, int lineNumber) {
        this.image = value.toString();
        this.type = tokenType;
        this.lineNumber = lineNumber;
    }

    public String getImage() {
        return this.image;
    }

    public TokenType getType() {
        return type;
    }

    public int getLineNumber() {
        return this.lineNumber;
    }

    @Override
    public boolean equals(Object obj) {
        Token rToken = (Token) obj;
        if (getImage().equals(rToken.getImage()) && getType().equals(rToken.getType())) {
            return true;
        }
        return false;
    }

    @Override
    public String toString() {
        return this.getType() + " " + this.getImage();
    }
}
